﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using NCC_SOP.app_codes;

namespace NCC_SOP.Admin
{
    public partial class retrievePwd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MultiView1.ActiveViewIndex = 0;
            if (!IsPostBack)
            {
                dbConnection db = new dbConnection();
                UserNameList.DataSource = db.getAllUsers();
                UserNameList.DataBind();
            }
        }
      
        protected void Click(object sender, EventArgs e)
        {
            try
            {
                string userName = UserNameList.SelectedValue;
                string password = Password.Text;
                MembershipUser mu = Membership.GetUser(userName);
                mu.ChangePassword(mu.ResetPassword(), password);
                ChangePasswordSuccess.Text = "You have successfully changed the password for " + userName + ".";
                MultiView1.ActiveViewIndex = 1;
            }
            catch (Exception e3)
            {
                Session["ErrorMessage"] = e3.Message;
                Response.Redirect("~/ErrorDisplayPage.aspx");
            }
        }

        protected void BackToHomePageButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/Default.aspx");
        }
    }
}